package com.cw.framework.handle;

import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.utils.SimpleReferenceCache;
import org.apache.dubbo.rpc.service.GenericService;

/**
 * dubbo接口泛化调用
 *
 * @author chenw
 */
public class DubboGenericServiceHandle {

    public GenericService getGenericService(String group, String interfaceName, String version) {
        SimpleReferenceCache simpleReferenceCache = SimpleReferenceCache.getCache();
        ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
        reference.setGeneric("true");
        reference.setInterface(interfaceName);
        reference.setVersion(version);
        reference.setGroup(group);
        reference.setCheck(false);
        reference.setTimeout(60000);
        return simpleReferenceCache.get(reference);
    }
}
